%{
#include "logit.h"
%}
/**
* Logit
*/

%rename (LogitModel) logitmodel;
%rename (LogitMcState) logitmcstate;
%rename (MNLReport) mnlreport;
struct logitmodel
{
    ap::real_1d_array w;
};
struct logitmcstate
{
    bool brackt;
    bool stage1;
    int infoc;
    double dg;
    double dgm;
    double dginit;
    double dgtest;
    double dgx;
    double dgxm;
    double dgy;
    double dgym;
    double finit;
    double ftest1;
    double fm;
    double fx;
    double fxm;
    double fy;
    double fym;
    double stx;
    double sty;
    double stmin;
    double stmax;
    double width;
    double width1;
    double xtrapf;
};
struct mnlreport
{
    int ngrad;
    int nhess;
};


void mnltrainh(const ap::real_2d_array& xy,
     int npoints,
     int nvars,
     int nclasses,
     int& info,
     logitmodel& lm,
     mnlreport& rep);

     
%rename(mnlprocess) wrap_mnlprocess;
%inline %{
VALUE wrap_mnlprocess(logitmodel& lm,
     const ap::real_1d_array& x) {
     ap::real_1d_array y;
//     y.setlength(lm.w(3));
     mnlprocess(lm,x,y);
     // std::cout << "Saliendo";
     return real1d_to_array(&y);
}
%}
     
     
     
void mnlunpack(const logitmodel& lm,
     ap::real_2d_array& a,
     int& nvars,
     int& nclasses);
     
void mnlpack(const ap::real_2d_array& a,
     int nvars,
     int nclasses,
     logitmodel& lm);

     
void mnlserialize(const logitmodel& lm, ap::real_1d_array& ra, int& rlen);
     
void mnlcopy(const logitmodel& lm1, logitmodel& lm2);

void mnlunserialize(const ap::real_1d_array& ra, logitmodel& lm);
double mnlavgce(logitmodel& lm, const ap::real_2d_array& xy, int npoints);
